package com.demo.dao.user;

import com.demo.entity.user.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * http://www.cnblogs.com/wangmingshun/p/5674633.html
 * 1、采用MapperScannerConfigurer，它将会查找类路径下的映射器并自动将它们创建成MapperFactoryBean。
 * spring-mybatis.xml:
 */
//@MapperScan
public interface UserDao {
    //------------------------------查找----------------------------------//
    List<User> findAll();

    User findUser(@Param("id") int id);

    User getUser(@Param("id") int id);

    User findByUserAndPass(@Param("username") String username, @Param("password") String password);

    /* 配置到了UserDaoPart.xml文件中 */
    User findUserByUsernamePassword(@Param("username") String username, @Param("password") String password);

    /* 用注解方式完成查询 */
    @Select("select * from t_user where username = #{userName}")
    User getUserByName(@Param("userName") String userName);

    /** select ... like username */
    List<User> findUserByUsername(String userName);

    //-----------------------------插入----------------------------------//

    int insert(User user);

    int insertSelective(User user);

    //-----------------------------更新----------------------------------//

    int updateByPrimaryKeySelective(User user);

    int updateByPrimaryKey(User user);

    //------------------------------删除---------------------------------//

    int deleteByPrimaryKey(Integer id);
}
